<?
class Control_Navigator extends QUI_Control_Abstract{
	
	function render(){
		$ctx = QContext::instance();
		if($ctx->action == 'onlineshop'){
			$items = array(array('name' => 'online shop'));
		}elseif($ctx->action == 'contactus'){
			$items = array(array('name' => 'contact us'));
		}elseif($ctx->action == 'aboutus'){
			$items = array(array('name' => 'about us'));
		}elseif($this->category){
			$items = $this->category->path();
		}elseif($this->product){
			$items = $this->product->path($this->pathIndex);
		}elseif($ctx->search){
			$items = array(array('name' => 'Search Result: '.$ctx->search));
		}else{
			$app = MyApp::instance();
			$currentProduct = $app->currentProduct();
			$currentCate = $app->currentCategory();
			
			if($currentProduct->id()){
				$items = $currentProduct->path();
			}elseif($currentCate->id()){
				$items = $currentCate->path();
			}
			
		}
		
		array_unshift($items, array('name'=>'home', 'url'=>url('default/')));
		$this->_view['items'] = $items;
		return $this->_fetchView(dirname(__FILE__) . '/navigator_view');
	}
}